<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @method static paginate(int $int)
 */
class Video extends Model
{
    use HasFactory;

    protected $fillable = ['title','path'];
    protected $hidden = ['path'];

    /**
     * @return BelongsTo
     */
    public function lesson(): BelongsTo
    {
        return $this->belongsTo(Lesson::class);
    }

    public function comments()
    {
        return $this->morphMany(Comment::class, 'commentable');
    }

    public function learnHistory()
    {
        return $this->belongsToMany(User::class,'learn_histories')->withTimestamps();
    }
}
